layui.use(['layer', 'form', 'admin', 'xnUtil', 'xmSelect', 'laydate','notice'], function () {
    var $ = layui.jquery;
    var layer = layui.layer;
    var form = layui.form;
    var admin = layui.admin;
    var xnUtil = layui.xnUtil;
    var xmSelect = layui.xmSelect;
    var laydate = layui.laydate;
    var notice = layui.notice;


    var editData = admin.getLayerData('#addOrUpdateForm').data;
    if(editData !== null && editData !== undefined) {
        form.val('addOrUpdateForm', editData);
    }

    /**
     * 表单提交事件
     */
    form.on('submit(formSubmitBtn)', function (data) {
        layer.load(2);
        var url = editData ? getProjectUrl() + 'singleelection/edit' : getProjectUrl() + 'singleelection/add';
        admin.req(url, JSON.stringify(data.field), function(res){
            layer.msg(res.message, {icon: 1, time: 1000}, function () {
                admin.putLayerData('formOk', true, '#addOrUpdateForm');
                admin.closeDialog('#addOrUpdateForm');
            });
        }, 'post');
        return false;
    });
    var index = 0;
    $("#addField").click(function (){
       alert(11)
        if(index > 25){
            notice.msg('不能再添加了!", "最多只能添加26个选项!', {icon: 2});
            this.FHFOPTION = '';
            return false;
        }
        if('' != this.FHFOPTION){
            arField[index] = arLetter[index]+' . '+this.FHFOPTION;
            this.appendC(arField[index]);
            this.FHFOPTION = '';
        }else{
            $("#FHFOPTION").tips({
                side:3,
                msg:'请输入选项',
                bg:'#AE81FF',
                time:2
            });
            this.FHFOPTION = '';
            this.$refs.FHFOPTION.focus();
        }
    });
});
